<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Class 与 Style 绑定-实现按钮点击加样式，再点取消样式</title>
    <script src="https://cdn.jsdelivr.net/npm/vue"></script>


    <script src="https://cdn.jsdelivr.net/npm/axios@0.12.0/dist/axios.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/lodash@4.13.1/lodash.min.js"></script>

    <style>
        .active{
            visibility: hidden;
        }
        .yangshi{
            color: green;
            font-weight: bold;
            font-size: 2rem;
        }
        .hasError{
            background-color: lightpink;
        }
        .myFont{
            color: blue;
            font-style: italic;
            font-size: 2rem;
        }
    </style>
</head>
<body>
<div id="app">
    <div :class="{active:isActive,yangshi:isYangshi}">可以传入v-bind属性来动态切换多个 class</div>

    <!--绑定计算属性-->
    <div :class="classObject">传入v-bind属性来动态切换多个 class
        <button v-on:click="clickBtn">按钮</button>
    </div>


</div>



<script>

    var app = new Vue({
        el: '#app',
        data: {
            isActive: true,//app.isActive=false显示
            isYangshi:false,
            error:false
        },
        methods:{
            clickBtn:function () {
                this.error=!this.error;

            }
        },
        computed:{
            classObject:function () {
                return {
                    hasError:this.error,//前面是样式class类名，后面是data里数据
                    myFont:this.error,
                }
            }
        },



    });

</script>
</body>
</html>
